package org.dk.domain;

import org.dk.em.DataResultEnum;

import java.io.Serializable;

public class DataResult<T> implements Serializable {

    private Integer code; //返回状态码100 成功  101 失败
    private String message; //状态信息
    private T data;

    /*手动封装*/
    public static DataResult buildDataResult(DataResultEnum Dr){
        DataResult dataResult = new DataResult(Dr.getCode(),Dr.getMessage());
        return dataResult;
    }

    public DataResult(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public DataResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public DataResult() {
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    //手动把返回值改一下
    public DataResult setData(T data) {
        this.data = data;
        return this;/*这里*/
    }
}
